package com.atguigu.ssyx.common.auth;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import javax.annotation.Resource;

@Configuration
public class LoginMvcConfigurerAdapter extends WebMvcConfigurationSupport {

    @Resource
    private RedisTemplate redisTemplate;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserLoginInterceptor(redisTemplate))  // 传入自定义的拦截器【额外处理一些公共内容】
                .addPathPatterns("/api/**")  // 指定要 拦截的接口路径
                .excludePathPatterns("/api/user/weixin/wxLogin/*"); // 排除一些指定的路径，不会被此拦截器拦截
        super.addInterceptors(registry);
    }
}
